package com.ruoyi.labdata.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.labdata.domain.LabRepairedDevice;
import com.ruoyi.labdata.service.ILabRepairedDeviceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 仪器维修Controller
 * 
 * @author winner pan
 * @date 2022-03-20
 */
@RestController
@RequestMapping("/labdata/repairedDevice")
public class LabRepairedDeviceController extends BaseController
{
    @Autowired
    private ILabRepairedDeviceService labRepairedDeviceService;

    /**
     * 查询仪器维修列表
     */
    //@PreAuthorize("@ss.hasPermi('labdata:repairedDevice:list')")
    @GetMapping("/list")
    public TableDataInfo list(LabRepairedDevice labRepairedDevice)
    {
        startPage();
        List<LabRepairedDevice> list = labRepairedDeviceService.selectLabRepairedDeviceList(labRepairedDevice);
        return getDataTable(list);
    }

    /**
     * 导出仪器维修列表
     */
    //@PreAuthorize("@ss.hasPermi('labdata:repairedDevice:export')")
    @Log(title = "仪器维修", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LabRepairedDevice labRepairedDevice)
    {
        List<LabRepairedDevice> list = labRepairedDeviceService.selectLabRepairedDeviceList(labRepairedDevice);
        ExcelUtil<LabRepairedDevice> util = new ExcelUtil<LabRepairedDevice>(LabRepairedDevice.class);
        return util.exportExcel(list, "repairedDevice");
    }

    /**
     * 获取仪器维修详细信息
     */
    //@PreAuthorize("@ss.hasPermi('labdata:repairedDevice:query')")
    @GetMapping(value = "/{instanceId}")
    public AjaxResult getInfo(@PathVariable("instanceId") Long instanceId)
    {
        return AjaxResult.success(labRepairedDeviceService.selectLabRepairedDeviceById(instanceId));
    }

    /**
     * 新增仪器维修
     */
    //@PreAuthorize("@ss.hasPermi('labdata:repairedDevice:add')")
    @Log(title = "仪器维修", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LabRepairedDevice labRepairedDevice)
    {
        return toAjax(labRepairedDeviceService.insertLabRepairedDevice(labRepairedDevice));
    }

    /**
     * 修改仪器维修
     */
    //@PreAuthorize("@ss.hasPermi('labdata:repairedDevice:edit')")
    @Log(title = "仪器维修", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LabRepairedDevice labRepairedDevice)
    {
        return toAjax(labRepairedDeviceService.updateLabRepairedDevice(labRepairedDevice));
    }

    /**
     * 删除仪器维修
     */
    //@PreAuthorize("@ss.hasPermi('labdata:repairedDevice:remove')")
    @Log(title = "仪器维修", businessType = BusinessType.DELETE)
	@DeleteMapping("/{instanceIds}")
    public AjaxResult remove(@PathVariable Long[] instanceIds)
    {
        return toAjax(labRepairedDeviceService.deleteLabRepairedDeviceByIds(instanceIds));
    }
}
